package com.mmd.base.config;

import com.mmd.base.hander.AuthorizationHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private AuthorizationHandler authorizationHandler;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("拦截器开始加载");
        registry.addInterceptor(authorizationHandler)
                .addPathPatterns("/**")
                .excludePathPatterns("/error","/swagger-ui.html","/swagger-resources/**","/webjars/**","/*/v2/api-docs","/v2/*","/doc.html");
        log.info("拦截器加载完毕");
    }
}
